﻿using System;

namespace DYWebApplication
{
    public partial class _Default : System.Web.UI.Page
    {
        public string postInfo = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataSetDBTableAdapters.AREASTableAdapter ad = new DataSetDBTableAdapters.AREASTableAdapter();
                var data = ad.GetData();
                var data1 = data.Clone();
                var data2 = data.Clone();
                foreach (DataSetDB.AREASRow dr in data.Rows)
                {
                    if (dr.HOMEAREA == "2")
                    {
                        data1.Rows.Add(dr.ItemArray);
                    }
                    else
                    {
                        data2.Rows.Add(dr.ItemArray);
                    }
                    
                }
                area.DataSource = data2;
                area.DataValueField = "AREANAME";
                area.DataTextField = "AREANAME";
                area.DataBind();

                qqSelect.DataSource = data1;
                qqSelect.DataValueField = "AREANAME";
                qqSelect.DataTextField = "AREANAME";
                qqSelect.DataBind();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            DataSetDB.PERSIONSDataTable pat = new DataSetDB.PERSIONSDataTable();
            DataSetDBTableAdapters.PERSIONSTableAdapter ad = new DataSetDBTableAdapters.PERSIONSTableAdapter();
          

            var phonedata = ad.GetDataByPhone(tel.Value.Trim());
            if (phonedata.Count > 0)
            {
                postInfo = "手机:" + tel.Value + "已经报名";
                return;
            }

            int pcountValue = 0;
            int.TryParse(pcount.Value.Trim(), out pcountValue);
            pat.AddPERSIONSRow(realname.Value.Trim(),qqSelect.Text, tel.Value.Trim(), work.Value.Trim(), pcountValue, area.Text,"未审核");
            ad.Update(pat);
            postInfo = "报名成功.";
        }
    }
}